package com.ruoyi.kq.scheduler;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import com.ruoyi.kq.mapper.WorkRecordMapper;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.mapper.SysUserMapper;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 文件名称: 上班
 * 功能描述:
 * 创建时间: 2025/3/17 17:41
 *
 * @author huangdelu
 */
@Component
public class TextMessageOnWorkTask {
    @Resource
    WorkRecordMapper workRecordMapper;
    @Resource
    SysUserMapper sysUserMapper;

    public void excute() {
        //今天时间
        String today = DateUtil.today();
        //用户表把所有人查出来除了admin
        List<SysUser> sysUsers = sysUserMapper.selectPeoList();
        if (CollectionUtil.isNotEmpty(sysUsers)) {
            for (SysUser sysUser : sysUsers) {
                Long userId = sysUser.getUserId();
                int i = workRecordMapper.selectPeoCount(String.valueOf(userId), today);
                if (i == 0) {
                    //今天没打卡，发送短信
                    System.out.println("用户id:" + userId + "今天没打卡");
                    //姓名
                    String nickName = sysUser.getNickName();
                }
            }
        }
    }
}
